import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

export function encrypt(txt,publicKey){
    const encryptor = new JSEncrypt();
    const keyStr = publicKey ? publicKey : 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAOjD0LmhB6YLMllRxzEDn6oMYkFQiN+2OKjt7Z2uoFWK0AH1Qk3D3dhUy2Cti318F7AQQ9L9qKKssYX6bF7A+esCAwEAAQ==';
    encryptor.setPublicKey(keyStr);
    return encryptor.encrypt(txt);
}

export function decrypt(txt,privateKey){
    const encryptor = new JSEncrypt();
    encryptor.setPrivateKey(privateKey);
    return encryptor.decrypt(txt);
}